<template>
  <div>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="id" label="ID" width="100"></el-table-column>
      <el-table-column prop="user_info.name" label="转让人"></el-table-column>
      <el-table-column prop="to_user_info.name" label="被转让人"></el-table-column>
      <el-table-column prop="status_text" label="状态"></el-table-column>
      <el-table-column prop="create_time" label="转让时间"></el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination
        @current-change ="handleCurrentChange"
        layout="total, prev, pager, next"
        :current-page="textData.current_page"
        :page-size="textData.per_page"
        :total="textData.total">
      </el-pagination>
    </div>
  </div>
</template>

<script scope>
  import {mapState} from 'vuex'

  export default {
    data () {
      return {
      }
    },
    computed: {
      ...mapState({
        tableData: state => state.certificate.transferList,
        textData: state => state.certificate.pageData
      })
    },
    created () {
      this.certificateTransfer()
    },
    methods: {
      async certificateTransfer () {
        let payload = {
          page: this.textData.current_page,
          listRows: this.textData.per_page,
          certificate_id: this.$route.params.id,
          keywords: ''
        }
        await this.$store.dispatch('certificate/certificateTransfer', payload)
      },
      handleCurrentChange (val) {
        this.textData.current_page = val
        this.certificateTransfer()
      }
    }
  }
</script>
